package com.kitty.game.gm.handler;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.gm.GmService;
import com.kitty.game.role.model.Role;
import com.kitty.mina.message.MessagePusher;

public class GmDaohangDown implements GMFather {

    @Override
    public boolean handle(Role gm, String content) {
        String[] strings = content.split("##");
        String name = strings[0];
        GmService gmService = SpringUtils.getBean(GmService.class);
        name = gmService.replaceName(name);
        Role role = SpringUtils.getRoleService().getOnlinePlayer(name);
        if (role == null) {
            long uid = gmService.getUidByName(name);
            role = SpringUtils.getRoleService().getPlayerBy(uid);
            if (role == null) {
                MessagePusher.pushMessage(gm, new RespNotifyMiscEx("角色不存在"));
                return true;
            }
        }
        SpringUtils.getRoleService().substractTao(role,Integer.parseInt(strings[1]));
        MessagePusher.pushMessage(gm,new RespNotifyMiscEx("减少道行成功！！"));
        return true;
    }
}
